#ifndef GRAPTH_H
#define GRAPTH_H

#include<algorithm>
#include<numeric>
#include<vector>
#include<iostream>
#include"simplePath.h"
#include"Node.h"
#include"flow.h"
#include"createGrapth.h" 
#include<queue>
#include<stack>






/*extern double trustMax[NUMOFNODE][NUMOFNODE];

					1,0.6,0.8,0,0,0,//1,0.5,0.6,0,0,//
					0.6,1,0.7,0.8,0.6,0.6,//0.5,1,0.5,0,0,//
					0.8,0.7,1,0.5,0,0,//0.6,0.5,1,0.6,0.7,//
					0,0.8,0.5,1,0.6,0,//0,0,0.6,1,0.8,//
					0,0.6,0,0.6,1,0.7,//0,0,0.7,0.8,1//
					0,0.6,0,0,0.7,1
};
*/

class Grapth{
	
public:
	int grapth_size;
	std::vector<Node> nodeVec;
	int flows;
	Grapth(){
		for(int i=0;i<NUMOFNODE;++i){
			Node ith_node(i);
			nodeVec.push_back(ith_node);
		}
		grapth_size=nodeVec.size();
		createMap();
		setNeibors(transmax);
	}

	Grapth(const Grapth &g):grapth_size(g.grapth_size),flows(g.flows){
		
		nodeVec=g.nodeVec;
		setNeibors(transmax);
	}

	void setNeibors(const int tranMap[][NUMOFNODE]);

	int discoverAllRoute(int pathS,int pathE);
	int discoverDSR(int pathS,int pathE);

	void setPathId(flow fw);
	void setFlowPath(flow fw);

	void setCoding_nodes(flow fw);
	bool coding_condition(int node,simplePath sp,CdPath &codingPath);
	bool combination(int coding_size,int choose_size);
	bool opration(CdPath &codingPath,std::vector<simplePath> coding_vec,std::vector< std::vector<int> > &com_result, simplePath sp,int node);
	bool isCoding_path(int node,simplePath sp,std::vector<simplePath> &coding_vec);
	bool two_path_coding(simplePath sp1,simplePath sp2,int node);
	bool more_than_three_coding(vector<simplePath> sp_vec,int node);
	void cut(simplePath simPath,std::vector<int> &beforeNodes,std::vector<int> &afterNodes,int node);
	void pure_cut(simplePath simPath,std::vector<int> &beforeNodes,std::vector<int> &afterNodes,int node);
	
	void cleanMark();
	void gclean();
	void gNode_power_init();

	void setPath_metric(flow fw, double trustProb);
	double path_cost(path p,double trustProb);
	void setMulti_Path_metric(flow fw,double trustProb);
	double multi_path_cost(path p,double trustProb);
	double formula_compt(int n,double trustProb);
	int formula_comb(int out_link_cnt,int choose_cnt);
	
};


#endif
